<import file="block/common.html" name="url"  :tpl_cfg="['urlName'=>$title,'backList'=>'返回列表']"/>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body ">
                <blockquote class="layui-elem-quote">修改角色权限后，用户不用重新登录，立即生效！</blockquote>
            </div>
        </div>
    </div>
</div>	
<div class="layui-form">
<form class="layui-form" action="" lay-filter="FormEdit" enctype="multipart/form-data">
  <fieldset class="layui-elem-field">
    <legend>角色名</legend>
    <div class="layui-field-box">
  <div class="layui-form-item">
    <label class="layui-form-label required">角色名</label>
    <div class="layui-input-inline">
        <input type="text" name="groupname" lay-verify="required" lay-reqtext="角色名不能为空" placeholder="请输入角色名!" value="" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">一般 为中文 如:XX部</div>
</div>
</div>
</fieldset>

  <fieldset class="layui-elem-field">
    <legend>后台管理</legend>
    <div class="layui-field-box">
     <div class="layui-form-item">
      <label class="layui-form-label">后台管理</label>
      <div class="layui-input-block">
        <input type="checkbox" name="systemrole" value="index_index" title="进入后台" checked="" disabled="">
        <input type="checkbox" name="systemrole" value="system_menu" title="系统设置">
        <input type="checkbox" name="systemrole" value="function_menu" title="内置功能">
      </div>
     </div>
     </div>
   </fieldset>
     
<fieldset class="layui-elem-field">
  <legend>系统管理</legend>
  <div class="layui-field-box">
 <div class="layui-form-item">
    <label class="layui-form-label">系统设置</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="system_index" title="查看">
      <input type="checkbox" name="systemrole" value="system_edit" title="编辑">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">缓存管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="cache_index" title="列表">
      <input type="checkbox" name="systemrole" value="cache_delFileCache" title="清除缓存">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">上传</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="upload_upload" title="上传">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">附件管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="attment_index" title="列表">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">系统公告</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="notice_index" title="列表">
      <input type="checkbox" name="systemrole" value="notice_add" title="添加">
      <input type="checkbox" name="systemrole" value="notice_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="notice_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">访问统计</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="visit_index" title="图形化展示">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">SQL日志</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="log_index" title="列表">
    </div>
  </div>  
</div>
</fieldset>

<fieldset class="layui-elem-field">
  <legend>管理员管理</legend>
  <div class="layui-field-box">
   <div class="layui-form-item">
    <label class="layui-form-label">角色管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="admingroup_index" title="列表">
      <input type="checkbox" name="systemrole" value="admingroup_add" title="添加">
      <input type="checkbox" name="systemrole" value="admingroup_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="admingroup_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">用户管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="adminuser_index" title="列表" >
      <input type="checkbox" name="systemrole" value="adminuser_add" title="添加">
      <input type="checkbox" name="systemrole" value="adminuser_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="adminuser_del" title="删除">
      <input type="checkbox" name="systemrole" value="adminuser_passwordedit" title="用户自主修改密码" >
    </div>
  </div>
  </div>
</fieldset>

<fieldset class="layui-elem-field">
  <legend>内容管理</legend>
  <div class="layui-field-box">
   <div class="layui-form-item">
    <label class="layui-form-label">栏目管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="contentcate_index" title="列表">
	    <input type="checkbox" name="systemrole" value="contentcate_add" title="添加">
      <input type="checkbox" name="systemrole" value="contentcate_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="contentcate_del" title="删除">
      <input type="checkbox" name="systemrole" value="content_cate_all" title="列表不受用户限制">
    </div>
    <div class="layui-form-mid layui-word-aux">如当前角色需要查看本级栏目其它成员发布的内容，请勾选 “列表不受用户限制”。</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">内容管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="content_index" title="列表">
	    <input type="checkbox" name="systemrole" value="content_add" title="添加">
      <input type="checkbox" name="systemrole" value="content_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="content_attribute" title="属性">
      <input type="checkbox" name="systemrole" value="content_status" title="发布">
      <input type="checkbox" name="systemrole" value="content_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">发布统计</label>
    <div class="layui-input-block">     
      <input type="checkbox" name="systemrole" value="contentcount_index" title="查看发布量统计">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">专题管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="contentspecial_index" title="列表">
	    <input type="checkbox" name="systemrole" value="contentspecial_add" title="添加">
      <input type="checkbox" name="systemrole" value="contentspecial_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="contentspecial_del" title="删除">
    </div>
  </div>  
  <div class="layui-form-item">
    <label class="layui-form-label">视频管理</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="videocate_index" title="栏目列表">
      <input type="checkbox" name="systemrole" value="videocate_add" title="添加">
      <input type="checkbox" name="systemrole" value="videocate_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="videocate_del" title="删除">
    </div>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="video_index" title="内容列表" >
      <input type="checkbox" name="systemrole" value="video_add" title="添加">
      <input type="checkbox" name="systemrole" value="video_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="video_del" title="删除">
    </div>
  </div>
  </div>
</fieldset>

<fieldset class="layui-elem-field">
  <legend>实用功能</legend>
  <div class="layui-field-box">
   <div class="layui-form-item">
    <label class="layui-form-label">值班排班</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="onduty_index" title="列表">
      <input type="checkbox" name="systemrole" value="onduty_add" title="添加">
      <input type="checkbox" name="systemrole" value="onduty_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="onduty_del" title="删除">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">图文图集</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="image_index" title="图集列表">
      <input type="checkbox" name="systemrole" value="image_add" title="添加">
      <input type="checkbox" name="systemrole" value="image_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="image_del" title="删除">
    </div>
	<div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="imageinfo_index" title="图文列表" >
      <input type="checkbox" name="systemrole" value="imageinfo_add" title="添加">
      <input type="checkbox" name="systemrole" value="imageinfo_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="imageinfo_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">成员信息</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="member_index" title="列表">
      <input type="checkbox" name="systemrole" value="member_add" title="添加">
      <input type="checkbox" name="systemrole" value="member_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="member_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">意见反馈</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="feedback_index" title="列表">
      <input type="checkbox" name="systemrole" value="feedback_add" title="添加" >
      <input type="checkbox" name="systemrole" value="feedback_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="feedback_del" title="删除">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">应用链接</label>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="applink_index" title="列表">
      <input type="checkbox" name="systemrole" value="applink_add" title="添加">
      <input type="checkbox" name="systemrole" value="applink_edit" title="编辑">
      <input type="checkbox" name="systemrole" value="applink_del" title="删除">
    </div>
    <div class="layui-input-block">
      <input type="checkbox" name="systemrole" value="applink_cateindex" title="分类列表">
      <input type="checkbox" name="systemrole" value="applink_cateadd" title="分类添加">
      <input type="checkbox" name="systemrole" value="applink_cateedit" title="分类编辑">
      <input type="checkbox" name="systemrole" value="applink_catedel" title="分类删除">
    </div>
  </div>
</div>
</fieldset>
<div class="layui-form-item">
    <div class="layui-input-block">
      <input type="hidden" name="id" value="">
      <button class="layui-btn" lay-submit lay-filter="saveBtn"><i class="layui-icon">&#x1005;</i><{lang('save')}></button>
    </div>
</div>
</form>
</div>
</div>
<script>
layui.define(function () {
    var form = layui.form,layer = layui.layer,$ = layui.$;
            
		form.render();

    if("<{ROUTE['act']}>"==="edit"){
        form.val('FormEdit', {
            "id": "<{$info['id']}>",
            "groupname": "<{$info['groupname']}>",
        });

        let data = JSON.parse('<{$info["systemrole"]}>');
        $.each(data, (v) => {
            let node = $(`input[type="checkbox"][name^="systemrole"][value="${data[v]}"]`);
            if (node && node.length) {
                node[0].checked = true;
                form.render('checkbox');
            }
        });
    }

    form.on('submit(saveBtn)', function (data) {
      let quotation = new Array();
      $("input:checkbox[name='systemrole']:checked").each(function () {
          quotation.push($(this).val());
      });
      data.field.systemrole = JSON.stringify(quotation);

			$.post('<{CAUrl("admingroup",ROUTE["act"])}>',data.field,function(res){
          if(res.status == 1){
              layer.msg(res.info, {icon: 1, time: 1000},function(){
              loadMain('<{CAUrl("admingroup","index")}>');
            });
          }else{
              layer.msg(res.info, {icon: 2, anim: 6, time: 5000});
          }
        });
        return false;
      });
    });
</script>